home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / PInterfaces / fp.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  26.0 KB  |  620 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        fp.p
  3.  
  4.      Contains:    FPCE Floating-Point Definitions and Declarations.
  5.  
  6.      Version:    Technology:    MathLib v2
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1987-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT fp;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __FP__}
  27. {$SETC __FP__ := 1}
  28.  
  29. {$I+}
  30. {$SETC fpIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __CONDITIONALMACROS__}
  34. {$I ConditionalMacros.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __MACTYPES__}
  37. {$I MacTypes.p}
  38. {$ENDC}
  39.  
  40. {*******************************************************************************
  41. *                                                                               *
  42. *    A collection of numerical functions designed to facilitate a wide          *
  43. *    range of numerical programming as required by C9X.                         *
  44. *                                                                               *
  45. *    The <fp.h> declares many functions in support of numerical programming.    *
  46. *    It provides a superset of <math.h> and <SANE.h> functions.  Some           *
  47. *    functionality previously found in <SANE.h> and not in the FPCE <fp.h>      *
  48. *    can be found in this <fp.h> under the heading "__NOEXTENSIONS__".          *
  49. *                                                                               *
  50. *    All of these functions are IEEE 754 aware and treat exceptions, NaNs,      *
  51. *    positive and negative zero and infinity consistent with the floating-      *
  52. *    point standard.                                                            *
  53. *                                                                               *
  54. *******************************************************************************}
  55.  
  56.  
  57. {$PUSH}
  58. {$ALIGN MAC68K}
  59. {$LibExport+}
  60.  
  61. {*******************************************************************************
  62. *                                                                               *
  63. *                            Efficient types                                    *
  64. *                                                                               *
  65. *    float_t         Most efficient type at least as wide as float              *
  66. *    double_t        Most efficient type at least as wide as double             *
  67. *                                                                               *
  68. *      CPU            float_t(bits)                double_t(bits)               *
  69. *    --------        -----------------            -----------------             *
  70. *    PowerPC          float(32)                    double(64)                   *
  71. *    68K              long double(80/96)           long double(80/96)           *
  72. *    x86              long double(80)              long double(80)              *
  73. *                                                                               *
  74. *******************************************************************************}
  75. {$IFC TARGET_CPU_PPC }
  76.  
  77. TYPE
  78.     float_t                                = Single;
  79.     double_t                            = Double;
  80. {$ELSEC}
  81. {$IFC TARGET_CPU_68K }
  82. TYPE
  83.     float_t                             = extended;
  84.     double_t                            = extended;
  85. {$ELSEC}
  86. {$IFC TARGET_CPU_X86 }
  87. {$IFC NeXT }
  88.  
  89. TYPE
  90.     float_t                                = Double;
  91.     double_t                            = Double;
  92. {$ELSEC}
  93.  
  94. TYPE
  95.     float_t                                = LongDouble;
  96.     double_t                            = LongDouble;
  97. {$ENDC}
  98. {$ELSEC}
  99. {$IFC TARGET_CPU_MIPS }
  100.  
  101. TYPE
  102.     float_t                                = Double;
  103.     double_t                            = Double;
  104. {$ELSEC}
  105. {$IFC TARGET_CPU_ALPHA }
  106.  
  107. TYPE
  108.     float_t                                = Double;
  109.     double_t                            = Double;
  110. {$ELSEC}
  111. {$IFC TARGET_CPU_SPARC }
  112.  
  113. TYPE
  114.     float_t                                = Double;
  115.     double_t                            = Double;
  116. {$ELSEC}
  117. { Unsupported CPU }
  118. {$ENDC}
  119. {$ENDC}
  120. {$ENDC}
  121. {$ENDC}
  122. {$ENDC}
  123. {$ENDC}
  124.  
  125.  
  126. {*******************************************************************************
  127. *                                                                               *
  128. *                              Define some constants.                           *
  129. *                                                                               *
  130. *    HUGE_VAL            IEEE 754 value of infinity.                            *
  131. *    INFINITY            IEEE 754 value of infinity.                            *
  132. *    NAN                 A generic NaN (Not A Number).                          *
  133. *    DECIMAL_DIG         Satisfies the constraint that the conversion from      *
  134. *                        double to decimal and back is the identity function.   *
  135. *                                                                               *
  136. *******************************************************************************}
  137.  
  138. CONST
  139. {$IFC TARGET_CPU_PPC }
  140.     DECIMAL_DIG                            = 17;  
  141. {$ELSEC}
  142.     DECIMAL_DIG                            = 21;
  143. {$ENDC}
  144.  
  145. {$IFC TARGET_OS_MAC }
  146. {*******************************************************************************
  147. *                                                                               *
  148. *                            Trigonometric functions                            *
  149. *                                                                               *
  150. *   acos        result is in [0,pi].                                            *
  151. *   asin        result is in [-pi/2,pi/2].                                      *
  152. *   atan        result is in [-pi/2,pi/2].                                      *
  153. *   atan2       Computes the arc tangent of y/x in [-pi,pi] using the sign of   *
  154. *               both arguments to determine the quadrant of the computed value. *
  155. *                                                                               *
  156. *******************************************************************************}
  157. FUNCTION cos(x: double_t): double_t; C;
  158. FUNCTION sin(x: double_t): double_t; C;
  159. FUNCTION tan(x: double_t): double_t; C;
  160. FUNCTION acos(x: double_t): double_t; C;
  161. FUNCTION asin(x: double_t): double_t; C;
  162. FUNCTION atan(x: double_t): double_t; C;
  163. FUNCTION atan2(y: double_t; x: double_t): double_t; C;
  164.  
  165.  
  166. {*******************************************************************************
  167. *                                                                                *
  168. *                              Hyperbolic functions                             *
  169. *                                                                                *
  170. *******************************************************************************}
  171. FUNCTION cosh(x: double_t): double_t; C;
  172. FUNCTION sinh(x: double_t): double_t; C;
  173. FUNCTION tanh(x: double_t): double_t; C;
  174. FUNCTION acosh(x: double_t): double_t; C;
  175. FUNCTION asinh(x: double_t): double_t; C;
  176. FUNCTION atanh(x: double_t): double_t; C;
  177.  
  178.  
  179. {*******************************************************************************
  180. *                                                                                *
  181. *                              Exponential functions                               *
  182. *                                                                                *
  183. *    expm1        expm1(x) = exp(x) - 1.  But, for small enough arguments,          *
  184. *                expm1(x) is expected to be more accurate than exp(x) - 1.        *
  185. *    frexp        Breaks a floating-point number into a normalized fraction       *
  186. *                and an integral power of 2.  It stores the integer in the       *
  187. *                object pointed by *exponent.                                    *
  188. *    ldexp        Multiplies a floating-point    number by an integer power of 2.    *
  189. *    log1p        log1p = log(1 + x). But, for small enough arguments,              *
  190. *                 log1p is expected to be more accurate than log(1 + x).          *
  191. *    logb        Extracts the exponent of its argument, as a signed integral        *
  192. *                  value. A subnormal argument is treated as though it were first    *
  193. *                  normalized. Thus:                                                *
  194. *                                     1   <=   x * 2^(-logb(x))   <   2             *
  195. *    modf        Returns fractional part of x as function result and returns     *
  196. *                integral part of x via iptr. Note C9X uses double not double_t.    *
  197. *    scalb        Computes x * 2^n efficently.  This is not normally done by        *
  198. *                  computing 2^n explicitly.                                         *
  199. *                                                                                *
  200. *******************************************************************************}
  201. FUNCTION exp(x: double_t): double_t; C;
  202. FUNCTION expm1(x: double_t): double_t; C;
  203. FUNCTION exp2(x: double_t): double_t; C;
  204. FUNCTION frexp(x: double_t; VAR exponent: LONGINT): double_t; C;
  205. FUNCTION ldexp(x: double_t; n: LONGINT): double_t; C;
  206. FUNCTION log(x: double_t): double_t; C;
  207. FUNCTION log2(x: double_t): double_t; C;
  208. FUNCTION log1p(x: double_t): double_t; C;
  209. FUNCTION log10(x: double_t): double_t; C;
  210. FUNCTION logb(x: double_t): double_t; C;
  211. FUNCTION modf(x: double_t; VAR iptr: double_t): double_t; C;
  212. FUNCTION modff(x: Single; VAR iptrf: Single): Single; C;
  213. FUNCTION scalb(x: double_t; n: LONGINT): double_t; C;
  214.  
  215.  
  216. {*******************************************************************************
  217. *                                                                                *
  218. *                     Power and absolute value functions                          *
  219. *                                                                                *
  220. *    hypot        Computes the square root of the sum of the squares of its        *
  221. *                  arguments, without undue overflow or underflow.                 *
  222. *    pow            Returns x raised to the power of y.  Result is more accurate    *
  223. *                than using exp(log(x)*y).                                        *
  224. *                                                                                *
  225. *******************************************************************************}
  226. FUNCTION fabs(x: double_t): double_t; C;
  227. FUNCTION hypot(x: double_t; y: double_t): double_t; C;
  228. FUNCTION pow(x: double_t; y: double_t): double_t; C;
  229. FUNCTION sqrt(x: double_t): double_t; C;
  230.  
  231.  
  232. {*******************************************************************************
  233. *                                                                                 *
  234. *                        Gamma and Error functions                               *
  235. *                                                                                 *
  236. *     erf            The error function.                                             *
  237. *     erfc        Complementary error function.                                      *
  238. *     gamma        The gamma function.                                                *
  239. *     lgamma        Computes the base-e logarithm of the absolute value of            *
  240. *                 gamma of its argument x, for x > 0.                                *
  241. *                                                                                 *
  242. *******************************************************************************}
  243. FUNCTION erf(x: double_t): double_t; C;
  244. FUNCTION erfc(x: double_t): double_t; C;
  245. FUNCTION gamma(x: double_t): double_t; C;
  246. FUNCTION lgamma(x: double_t): double_t; C;
  247.  
  248.  
  249. {*******************************************************************************
  250. *                                                                                 *
  251. *                        Nearest integer functions                                 *
  252. *                                                                                 *
  253. *     rint        Rounds its argument to an integral value in floating point         *
  254. *                  format, honoring the current rounding direction.                   *
  255. *                                                                                 *
  256. *     nearbyint    Differs from rint only in that it does not raise the inexact    *
  257. *               exception. It is the nearbyint function recommended by the        *
  258. *                  IEEE floating-point standard 854.                                  *
  259. *                                                                                 *
  260. *     rinttol        Rounds its argument to the nearest long int using the current     *
  261. *                  rounding direction.  NOTE: if the rounded value is outside        *
  262. *                the range of long int, then the result is undefined.              *
  263. *                                                                                  *
  264. *     round        Rounds the argument to the nearest integral value in floating     *
  265. *                  point format similar to the Fortran "anint" function. That is:  *
  266. *                  add half to the magnitude and chop.                             *
  267. *                                                                                 *
  268. *     roundtol    Similar to the Fortran function nint or to the Pascal round.    *
  269. *                 NOTE: if the rounded value is outside the range of long int,    *
  270. *                  then the result is undefined.                                      *
  271. *                                                                                 *
  272. *     trunc        Computes the integral value, in floating format, nearest to        *
  273. *                 but no larger in magnitude than its argument.      NOTE: on 68K    *
  274. *                compilers when using -elems881, trunc must return an int        *
  275. *                                                                                 *
  276. *******************************************************************************}
  277. FUNCTION ceil(x: double_t): double_t; C;
  278. FUNCTION floor(x: double_t): double_t; C;
  279. FUNCTION rint(x: double_t): double_t; C;
  280. FUNCTION nearbyint(x: double_t): double_t; C;
  281. FUNCTION rinttol(x: double_t): LONGINT; C;
  282. FUNCTION round(x: double_t): double_t; C;
  283. FUNCTION roundtol(round: double_t): LONGINT; C;
  284. {$IFC TARGET_CPU_68K }
  285. FUNCTION trunc(x: double_t): LONGINT; C;
  286. {$ELSEC}
  287. FUNCTION trunc(x: double_t): double_t; C;
  288. {$ENDC}
  289.  
  290. {*******************************************************************************
  291. *                                                                                 *
  292. *                            Remainder functions                                   *
  293. *                                                                                 *
  294. *     remainder        IEEE 754 floating point standard for remainder.                *
  295. *     remquo            SANE remainder.  It stores into 'quotient' the 7 low-order    *
  296. *                    bits of the integer quotient x/y, such that:                *
  297. *                        -127 <= quotient <= 127.                                 *
  298. *                                                                                 *
  299. *******************************************************************************}
  300. FUNCTION fmod(x: double_t; y: double_t): double_t; C;
  301. FUNCTION remainder(x: double_t; y: double_t): double_t; C;
  302. FUNCTION remquo(x: double_t; y: double_t; VAR quo: LONGINT): double_t; C;
  303.  
  304.  
  305. {*******************************************************************************
  306. *                                                                                 *
  307. *                             Auxiliary functions                               *
  308. *                                                                                 *
  309. *     copysign        Produces a value with the magnitude of its first argument    *
  310. *                      and sign of its second argument.  NOTE: the order of the     *
  311. *                      arguments matches the recommendation of the IEEE 754         *
  312. *                    floating point standard,  which is opposite from the SANE    *
  313. *                    copysign function.                                             *
  314. *                                                                                 *
  315. *     nan                The call 'nan("n-char-sequence")' returns a quiet NaN         *
  316. *                      with content indicated through tagp in the selected         *
  317. *                    data type format.                                              *
  318. *                                                                                *
  319. *     nextafter        Computes the next representable value after 'x' in the         *
  320. *                    direction of 'y'.  if x == y, then y is returned.            *
  321. *                                                                                 *
  322. *******************************************************************************}
  323. FUNCTION copysign(x: double_t; y: double_t): double_t; C;
  324. FUNCTION nan(tagp: ConstCStringPtr): Double; C;
  325. FUNCTION nanf(tagp: ConstCStringPtr): Single; C;
  326. FUNCTION nextafterd(x: Double; y: Double): Double; C;
  327. FUNCTION nextafterf(x: Single; y: Single): Single; C;
  328.  
  329.  
  330. {*******************************************************************************
  331. *                                                                                 *
  332. *                              Inquiry macros                                   *
  333. *                                                                                 *
  334. *     fpclassify        Returns one of the FP_≈ values.                                *
  335. *     isnormal        Non-zero if and only if the argument x is normalized.          *
  336. *     isfinite        Non-zero if and only if the argument x is finite.             *
  337. *     isnan            Non-zero if and only if the argument x is a NaN.              *
  338. *     signbit            Non-zero if and only if the sign of the argument x is        *
  339. *                      negative.  This includes, NaNs, infinities and zeros.         *
  340. *                                                                                 *
  341. *******************************************************************************}
  342.  
  343. CONST
  344.     FP_SNAN                        = 0;                            {       signaling NaN                          }
  345.     FP_QNAN                        = 1;                            {       quiet NaN                              }
  346.     FP_INFINITE                    = 2;                            {       + or - infinity                        }
  347.     FP_ZERO                        = 3;                            {       + or - zero                            }
  348.     FP_NORMAL                    = 4;                            {       all normal numbers                     }
  349.     FP_SUBNORMAL                = 5;                            {       denormal numbers                       }
  350.  
  351.  
  352.  
  353. FUNCTION __fpclassifyd(x: Double): LONGINT; C;
  354. FUNCTION __fpclassifyf(x: Single): LONGINT; C;
  355. FUNCTION __isnormald(x: Double): LONGINT; C;
  356. FUNCTION __isnormalf(x: Single): LONGINT; C;
  357. FUNCTION __isfinited(x: Double): LONGINT; C;
  358. FUNCTION __isfinitef(x: Single): LONGINT; C;
  359. FUNCTION __isnand(x: Double): LONGINT; C;
  360. FUNCTION __isnanf(x: Single): LONGINT; C;
  361. FUNCTION __signbitd(x: Double): LONGINT; C;
  362. FUNCTION __signbitf(x: Single): LONGINT; C;
  363. FUNCTION __inf: double_t; C;
  364.  
  365.  
  366. {*******************************************************************************
  367. *                                                                                 *
  368. *                      Max, Min and Positive Difference                         *
  369. *                                                                                 *
  370. *     fdim        Determines the 'positive difference' between its arguments:     *
  371. *                ( x - y, if x > y ), ( +0, if x <= y ).  If one argument is        *
  372. *                  NaN, then fdim returns that NaN.  if both arguments are NaNs,     *
  373. *                 then fdim returns the first argument.                            *
  374. *                                                                                 *
  375. *     fmax        Returns the maximum of the two arguments.  Corresponds to the    *
  376. *                max function in FORTRAN.  NaN arguments are treated as missing     *
  377. *                data.  If one argument is NaN and the other is a number, then     *
  378. *                the number is returned.  If both are NaNs then the first         *
  379. *                argument is returned.                                             *
  380. *                                                                                 *
  381. *     fmin        Returns the minimum of the two arguments.  Corresponds to the    *
  382. *                min function in FORTRAN.  NaN arguments are treated as missing     *
  383. *                data.  If one argument is NaN and the other is a number, then     *
  384. *                the number is returned.  If both are NaNs then the first         *
  385. *                argument is returned.                                            *
  386. *                                                                                 *
  387. *******************************************************************************}
  388. FUNCTION fdim(x: double_t; y: double_t): double_t; C;
  389. FUNCTION fmax(x: double_t; y: double_t): double_t; C;
  390. FUNCTION fmin(x: double_t; y: double_t): double_t; C;
  391.  
  392.  
  393. {******************************************************************************
  394. *                                Constants                                     *
  395. ******************************************************************************}
  396. {$IFC NOT UNDEFINED MWERKS}
  397.     {$IFC MWERKS > $1500}
  398.         CONST pi : double_t = 3.1415926535;
  399.     {$ENDC}
  400. {$ENDC}
  401.  
  402.  
  403. {*******************************************************************************
  404. *                                                                                 *
  405. *                              Non NCEG extensions                                *
  406. *                                                                                 *
  407. *******************************************************************************}
  408. {$IFC UNDEFINED __NOEXTENSIONS__ }
  409. {*******************************************************************************
  410. *                                                                                 *
  411. *                              Financial functions                              *
  412. *                                                                                 *
  413. *     compound        Computes the compound interest factor "(1 + rate)^periods"    *
  414. *                      more accurately than the straightforward computation with     *
  415. *                    the Power function.  This is SANE's compound function.      *
  416. *                                                                                 *
  417. *     annuity            Computes the present value factor for an annuity             *
  418. *                      "(1 - (1 + rate)^(-periods)) /rate" more accurately than    *
  419. *                    the straightforward computation with the Power function.     *
  420. *                    This is SANE's annuity function.                              *
  421. *                                                                                 *
  422. *******************************************************************************}
  423. FUNCTION compound(rate: double_t; periods: double_t): double_t; C;
  424. FUNCTION annuity(rate: double_t; periods: double_t): double_t; C;
  425.  
  426.  
  427. {*******************************************************************************
  428. *                                                                                 *
  429. *                              Random function                                  *
  430. *                                                                                 *
  431. *     randomx            A pseudorandom number generator.  It uses the iteration:    *
  432. *                                (7^5*x)mod(2^31-1)                                *
  433. *                                                                                 *
  434. *******************************************************************************}
  435. FUNCTION randomx(VAR x: double_t): double_t; C;
  436.  
  437.  
  438. {******************************************************************************
  439. *                              Relational operator                             *
  440. ******************************************************************************}
  441. {      relational operator      }
  442.  
  443. TYPE
  444.     relop                                = INTEGER;
  445.  
  446. CONST
  447.     GREATERTHAN                    = 0;
  448.     LESSTHAN                    = 1;
  449.     EQUALTO                        = 2;
  450.     UNORDERED                    = 3;
  451.  
  452. FUNCTION relation(x: double_t; y: double_t): relop; C;
  453.  
  454.  
  455. {*******************************************************************************
  456. *                                                                                 *
  457. *                         Binary to decimal conversions                         *
  458. *                                                                                 *
  459. *     SIGDIGLEN    Significant decimal digits.                                        *
  460. *                                                                                 *
  461. *     decimal        A record which provides an intermediate unpacked form for        *
  462. *                programmers who wish to do their own parsing of numeric input     *
  463. *                or formatting of numeric output.                                  *
  464. *                                                                                 *
  465. *     decform        Controls each conversion to a decimal string.  The style field     *
  466. *                is either FLOATDECIMAL or FIXEDDECIMAL. If FLOATDECIMAL, the     *
  467. *                value of the field digits is the number of significant digits.  *
  468. *                  If FIXEDDECIMAL value of the field digits is the number of        *
  469. *                digits to the right of the decimal point.                         *
  470. *                                                                                 *
  471. *     num2dec        Converts a double_t to a decimal record    using a decform.        *
  472. *     dec2num        Converts a decimal record d to a double_t value.                *
  473. *     dec2str        Converts a decform and decimal to a string using a decform.        *
  474. *     str2dec        Converts a string to a decimal struct.                            *
  475. *     dec2d        Similar to dec2num except a double is returned (68k only).        *
  476. *     dec2f        Similar to dec2num except a float is returned.                    *
  477. *     dec2s        Similar to dec2num except a short is returned.                    *
  478. *     dec2l        Similar to dec2num except a long is returned.                     *
  479. *                                                                                 *
  480. *******************************************************************************}
  481.  
  482. CONST
  483. {$IFC TARGET_CPU_PPC }
  484.     SIGDIGLEN                    = 36;
  485. {$ELSEC}
  486.     SIGDIGLEN                    = 20;
  487. {$ENDC}
  488.     DECSTROUTLEN                = 80;
  489. TYPE
  490.     DecimalKind = (FLOATDECIMAL, FIXEDDECIMAL);
  491.  
  492.  
  493.     Decimal = RECORD
  494.         sgn:     0..1;            { sign 0 for +, 1 for -  }
  495.         exp:     INTEGER;
  496.         sig:     STRING[SIGDIGLEN];
  497.     END;
  498.  
  499.     Decform = RECORD
  500.         style:     DecimalKind;
  501.         digits: INTEGER;
  502.     END;
  503.  
  504. PROCEDURE num2dec({CONST}VAR f: decform; x: double_t; VAR d: decimal); C;
  505. FUNCTION dec2num({CONST}VAR d: decimal): double_t; C;
  506. PROCEDURE dec2str({CONST}VAR f: decform; {CONST}VAR d: decimal; s: CStringPtr); C;
  507. PROCEDURE str2dec(s: ConstCStringPtr; VAR ix: INTEGER; VAR d: decimal; VAR vp: INTEGER); C;
  508. {$IFC TARGET_CPU_68K }
  509. FUNCTION dec2d({CONST}VAR d: decimal): Double; C;
  510. {$ENDC}
  511. FUNCTION dec2f({CONST}VAR d: decimal): Single; C;
  512. FUNCTION dec2s({CONST}VAR d: decimal): INTEGER; C;
  513. FUNCTION dec2l({CONST}VAR d: decimal): LONGINT; C;
  514.  
  515.  
  516.  
  517. {*******************************************************************************
  518. *                                                                                 *
  519. *                         68k-only Transfer Function Prototypes                 *
  520. *                                                                                 *
  521. *******************************************************************************}
  522. {$IFC TARGET_CPU_68K }
  523. {$IFC TARGET_RT_MAC_68881 }
  524. PROCEDURE x96tox80({CONST}VAR x: extended96; VAR x80: extended80); C;
  525. PROCEDURE x80tox96({CONST}VAR x80: extended80; VAR x: extended96); C;
  526. {$ELSEC}
  527. PROCEDURE x96tox80({CONST}VAR x96: extended96; VAR x: extended80); C;
  528. PROCEDURE x80tox96({CONST}VAR x: extended80; VAR x96: extended96); C;
  529. {$ENDC}
  530. {$ENDC}
  531. {$ENDC}
  532. {*******************************************************************************
  533. *                                                                                 *
  534. *                         PowerPC-only Function Prototypes                         *
  535. *                                                                                 *
  536. *******************************************************************************}
  537.  
  538. {$IFC TARGET_CPU_PPC }
  539. FUNCTION cosl(x: LongDouble): LongDouble; C;
  540. FUNCTION sinl(x: LongDouble): LongDouble; C;
  541. FUNCTION tanl(x: LongDouble): LongDouble; C;
  542. FUNCTION acosl(x: LongDouble): LongDouble; C;
  543. FUNCTION asinl(x: LongDouble): LongDouble; C;
  544. FUNCTION atanl(x: LongDouble): LongDouble; C;
  545. FUNCTION atan2l(y: LongDouble; x: LongDouble): LongDouble; C;
  546. FUNCTION coshl(x: LongDouble): LongDouble; C;
  547. FUNCTION sinhl(x: LongDouble): LongDouble; C;
  548. FUNCTION tanhl(x: LongDouble): LongDouble; C;
  549. FUNCTION acoshl(x: LongDouble): LongDouble; C;
  550. FUNCTION asinhl(x: LongDouble): LongDouble; C;
  551. FUNCTION atanhl(x: LongDouble): LongDouble; C;
  552. FUNCTION expl(x: LongDouble): LongDouble; C;
  553. FUNCTION expm1l(x: LongDouble): LongDouble; C;
  554. FUNCTION exp2l(x: LongDouble): LongDouble; C;
  555. FUNCTION frexpl(x: LongDouble; VAR exponent: LONGINT): LongDouble; C;
  556. FUNCTION ldexpl(x: LongDouble; n: LONGINT): LongDouble; C;
  557. FUNCTION logl(x: LongDouble): LongDouble; C;
  558. FUNCTION log1pl(x: LongDouble): LongDouble; C;
  559. FUNCTION log10l(x: LongDouble): LongDouble; C;
  560. FUNCTION log2l(x: LongDouble): LongDouble; C;
  561. FUNCTION logbl(x: LongDouble): LongDouble; C;
  562. FUNCTION scalbl(x: LongDouble; n: LONGINT): LongDouble; C;
  563. FUNCTION fabsl(x: LongDouble): LongDouble; C;
  564. FUNCTION hypotl(x: LongDouble; y: LongDouble): LongDouble; C;
  565. FUNCTION powl(x: LongDouble; y: LongDouble): LongDouble; C;
  566. FUNCTION sqrtl(x: LongDouble): LongDouble; C;
  567. FUNCTION erfl(x: LongDouble): LongDouble; C;
  568. FUNCTION erfcl(x: LongDouble): LongDouble; C;
  569. FUNCTION gammal(x: LongDouble): LongDouble; C;
  570. FUNCTION lgammal(x: LongDouble): LongDouble; C;
  571. FUNCTION ceill(x: LongDouble): LongDouble; C;
  572. FUNCTION floorl(x: LongDouble): LongDouble; C;
  573. FUNCTION rintl(x: LongDouble): LongDouble; C;
  574. FUNCTION nearbyintl(x: LongDouble): LongDouble; C;
  575. FUNCTION rinttoll(x: LongDouble): LONGINT; C;
  576. FUNCTION roundl(x: LongDouble): LongDouble; C;
  577. FUNCTION roundtoll(round: LongDouble): LONGINT; C;
  578. FUNCTION truncl(x: LongDouble): LongDouble; C;
  579. FUNCTION remainderl(x: LongDouble; y: LongDouble): LongDouble; C;
  580. FUNCTION remquol(x: LongDouble; y: LongDouble; VAR quo: LONGINT): LongDouble; C;
  581. FUNCTION copysignl(x: LongDouble; y: LongDouble): LongDouble; C;
  582. FUNCTION fdiml(x: LongDouble; y: LongDouble): LongDouble; C;
  583. FUNCTION fmaxl(x: LongDouble; y: LongDouble): LongDouble; C;
  584. FUNCTION fminl(x: LongDouble; y: LongDouble): LongDouble; C;
  585.  
  586. {$IFC UNDEFINED __NOEXTENSIONS__ }
  587. FUNCTION relationl(x: LongDouble; y: LongDouble): relop; C;
  588. PROCEDURE num2decl({CONST}VAR f: decform; x: LongDouble; VAR d: decimal); C;
  589. FUNCTION dec2numl({CONST}VAR d: decimal): LongDouble; C;
  590. {    
  591.     MathLib v2 has two new transfer functions: x80tod and dtox80.  They can 
  592.     be used to directly transform 68k 80-bit extended data types to double
  593.     and back for PowerPC based machines without using the functions
  594.     x80told or ldtox80.  Double rounding may occur. 
  595. }
  596. PROCEDURE x80told({CONST}VAR x80: extended80; VAR x: LongDouble); C;
  597. PROCEDURE ldtox80({CONST}VAR x: LongDouble; VAR x80: extended80); C;
  598. FUNCTION x80tod({CONST}VAR x80: extended80): Double; C;
  599. PROCEDURE dtox80({CONST}VAR x: Double; VAR x80: extended80); C;
  600. {$ENDC}
  601. {$ENDC}
  602. {$ELSEC}
  603. {
  604.     Non-Mac platforms may have long doubles.
  605. }
  606. PROCEDURE x80told({CONST}VAR x80: extended80; VAR x: LongDouble); C;
  607. PROCEDURE ldtox80({CONST}VAR x: LongDouble; VAR x80: extended80); C;
  608. {$ENDC}  {TARGET_OS_MAC}
  609.  
  610. {$ALIGN RESET}
  611. {$POP}
  612.  
  613. {$SETC UsingIncludes := fpIncludes}
  614.  
  615. {$ENDC} {__FP__}
  616.  
  617. {$IFC NOT UsingIncludes}
  618.  END.
  619. {$ENDC}
  620.